package com.fhz.mvvmtest.food2;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;
import android.widget.Toast;

import com.fhz.mvvmtest.R;
import com.fhz.mvvmtest.base.BaseMVVMActivity;
import com.fhz.mvvmtest.databinding.ActivityFood2Binding;
import com.fhz.mvvmtest.food.entity.Food;
import com.fhz.mvvmtest.food2.viewmodel.FoodViewModel2;
import com.fhz.mvvmtest.food2.viewmodel.FoodViewModelFactory2;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author: fhz
 * @describe:
 * @date: 2021-11-15 14:07:38
 */

public class Food2Activity  extends BaseMVVMActivity<FoodViewModel2, ActivityFood2Binding> {

    @Override
    protected FoodViewModel2 createViewModel() {
        return ViewModelProviders.of(this,new FoodViewModelFactory2()).get(FoodViewModel2.class);
    }

    @Override
    protected int layoutId() {
        return R.layout.activity_food2;
    }

    @Override
    protected void initData() {

        viewModel.getFood().observe(this, new Observer<Food>() {
            @Override
            public void onChanged(Food food) {
                bingding.setFood(food);
                Toast.makeText(Food2Activity.this, "daxia"+food.getData().size(), Toast.LENGTH_SHORT).show();
            }
        });

    }
}
